﻿
$(document).ready(function () {
    $("#ContentPlaceHolder1_submit").click(function (e) {
        var str1 = document.getElementById("ContentPlaceHolder1_username").value;

        if (str1 == null || str1 == "") {
            $("#ContentPlaceHolder1_checkusername").text("");
            $("#ContentPlaceHolder1_checkusername").append('<div style="height:34px"  class="alert alert-danger" role="alert">用户名不能为空</span>');

        }

        var str2 = document.getElementById("ContentPlaceHolder1_password").value;
 
        if (str2 == null || str2 == "") {
            $("#ContentPlaceHolder1_checkpassword").text("");
            $("#ContentPlaceHolder1_checkpassword").append('<span class="alert alert-danger" role="alert" height=34px>密码不能为空</span>');  
        }

        if (!checkstr(str1) || !checkstr(str2)) {
            alert("填写错误!");
            e.preventDefault();
        }

    });
});


$(document).ready(function () {


    $("#ContentPlaceHolder1_username").blur(function () {
        var str1 = document.getElementById("ContentPlaceHolder1_username").value;
        if (str1 == null || str1 == "") {
            $("#ContentPlaceHolder1_checkusername").text("");
            $("#ContentPlaceHolder1_checkusername").append('<span class="alert alert-danger" role="alert">用户名不能为空</span>');

        }
    });
    $("#ContentPlaceHolder1_password").blur(function () {
        var str2 = document.getElementById("ContentPlaceHolder1_password").value;
        if (str2 == null || str2 == "") {
            $("#ContentPlaceHolder1_checkpassword").text("");
            $("#ContentPlaceHolder1_checkpassword").append('<span class="alert alert-danger" role="alert" height=34px>密码不能为空</span>');
        }
    });
   
    $("#ContentPlaceHolder1_username").focus(function () {
        $("#ContentPlaceHolder1_checkusername").text("");
    });
    $("#ContentPlaceHolder1_password").focus(function () {
        $("#ContentPlaceHolder1_checkpassword").text("");
    });
   

});

function checkstr(str) {
    if (str == "" || str == null)
        return false;
    else
        return true;
}



